﻿#pragma once
#pragma execution_character_set("utf-8")
// 本文件为utf-8 编码格式

#ifndef __GD__GDClippingImageView__
#define __GD__GDClippingImageView__

#include "CrossApp.h"
#include "../Views/GDImageView.h"
#include "../DelegateClassDefine.h"

/* 图片裁剪 */
class GDClippingImageView :
	public CAView
	, public CommonUrlImageViewDelegate
{

public:
	static GDClippingImageView* createWithFrame(const CCRect& rect,CAImage *image,std::string imageUrl="");

	GDClippingImageView();

	virtual ~GDClippingImageView();
	
	void initView(CAImage *image, std::string imageUrl = "");

	virtual void imageViewRequestFinished(CommonUrlImageView* imageView);
	CAImage* clipImage(); // 裁剪图片

	void onCancelBtnClick(CrossApp::CAControl *control, CrossApp::CCPoint point);
	void onOkBtnClick(CrossApp::CAControl *control, CrossApp::CCPoint point);
protected:
	
	CC_SYNTHESIZE(GDClippingImageDelegate*, m_clippingImageDelegate, ClippingImageDelegate);
	void freshScrollView();
	CADrawView* getStencil(const CCSize& size, int index);
private:
	CAView *headNode; // 头部节点
	CAView *btmNode; // 底部节点
	CAScrollView *scrollView; // 滚动背景
	GDImageView *imageView; // 需要裁剪的图片
	CCSize winSize;
	float zhezhaoHeight; // 遮罩高度
	float btmZhezhaoHeight; // 底部遮罩高度
	CALabel *titleNabel; // 标题
	CAButton *cancelBtn; // 取消按钮
	CAButton *okBtn; // 确定按钮
	CAClippingView* m_clvImage;
	CAClippingView *m_clv;
};
#endif /* defined(__HelloCpp__ViewController__) */